<template>
  <div id="app">
    <music></music>
    <transition :name="switchover">
      <router-view></router-view>
    </transition>
  </div>
</template>

<script>
  import music from '@/components/music';

  export default {
    name: 'app',
    data: function () {
      return {
        switchover: ''
      }
    },
    components: {
      music
    },
    watch: {
      '$route' (to, from) {
        const toDepth = to.path.split('/').length;
        const fromDepth = from.path.split('/').length;
        this.switchover
          = toDepth === fromDepth ? 'fade' : (
          toDepth > fromDepth ? 'slide-right' : 'slide-left'
        );
      }
    }
  }
</script>

<style lang="scss">
  @import "assets/scss/config";

  html {
    font-size: $fontSize;
    min-height: $basisHeight;
  }

  #app {
    .section {
      .text_content {
        position: absolute;
        left: setRem(56px);
        right: setRem(56px);
        color: #E7C598;
        overflow: auto;

        .item {
          &:not(:first-child) {
            h4 {
              margin-top: setRem(24px);
            }
          }

          h4 {
            font-size: setRem(28px);
            line-height: 1em;
            margin-bottom: setRem(12px);
          }

          p {
            font-size: setRem(18px);
            line-height: setRem(32px);
          }
        }
      }

      .btn {
        position: absolute;
        left: setRem(56px);
        right: setRem(56px);
        width: setRem(230px);
        margin: auto;
        text-align: center;
        height: setRem(45px);

        img {
          position: absolute;
          left: -100%;
          right: -100%;
          top: 0;
          height: setRem(45px);
          margin: auto;
        }

        p {
          color: #E7C598;
          font-size: setRem(20px);
          line-height: setRem(45px);
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }
    }
  }

  .fade-enter-active,
  .fade-leave-active {
    transition: opacity .5s;
  }

  .fade-enter,
  .fade-leave-active {
    opacity: 0;
  }

  .slide-left-enter-active,
  .slide-left-leave-active,
  .slide-right-enter-active,
  .slide-right-leave-active {
    transition: transform 1s cubic-bezier(.41, .56, .15, .98);
  }

  .slide-left-leave-active {
    z-index: 1;
  }

  .slide-right-enter-active,
  .slide-left-leave-active {
    box-shadow: -1px 0 10px 0 rgba(0, 0, 0, 0.5);
  }

  .slide-left-enter,
  .slide-right-leave-active {
    transform: translateX(-50%);
  }

  .slide-right-enter,
  .slide-left-leave-active {
    transform: translateX(100%);
  }

  .slide-top-enter-active,
  .slide-top-leave-active,
  .slide-bottom-enter-active,
  .slide-bottom-leave-active {
    transition: transform 1s cubic-bezier(.41, .56, .15, .98);
  }

  .slide-top-enter,
  .slide-bottom-leave-active {
    transform: translateY(-100%);
  }

  .slide-bottom-enter,
  .slide-top-leave-active {
    transform: translateY(100%);
  }
</style>

<style lang="scss" scoped>
  #app {
    display: none;
    position: relative;
    height: 100%;
    margin: auto;
    overflow: hidden;
    color: #E7C598;
    background-color: #bf0c21;

    .section {
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      background: url("assets/images/shading.png") #bf0c21;
    }
  }
</style>
